<?php
if (eregi("admin.php",$_SERVER['SCRIPT_NAME'])) {
    #Header("Location: ../index.php");
    #die();
}


class Admin {

    // user data
        var $language = "";
    var $valid    = false;
    var $password = "taykyoku"; // admin password (md5 encrypted)


        // {{{ init()
    //
    // Initialisierung der Userdaten und loggt den Admin ggf. ein.
    //
    // IN: -
    // OUT: -
    //
    function init () {
            global $session,$_POST,$session_password;

                $session->create("session_password");
                    if ($session_password == $this->password || $_SESSION['password']==$this->password) { $this->valid = true; } // user is admin
                    else
                        {
                            if ($_POST["adminpass"] != "") { $this->login($_POST["adminpass"]); }
                        }
                $this->password = "";
				$this->language = $_SESSION['session_adminlang'];
    }
        // }}}


        // {{{ login()
    //
    // try to log in as admin.
    //
    // IN: varchar [$password: password]
    // OUT: -
    //
    function login ($password) {
        global $session_password;
        if ($password == $this->password)
                {
                    $this->valid = true;
                    $session_password = $password;
					$_SESSION['password'] = $password;
                }
    }
        // }}}

        // {{{ logout()
    //
    // logs the admin out.
    //
    // IN: -
    // OUT: -
    //
    function logout() {
            global $session,$html;
            $session->destroy("session_password");
                   $this->password = "";
                   $this->valid    = false;
				$_SESSION['password'] = "";
    }
        // }}}


        // {{{ setLang()
    //
    // Initialisierung der Adminsprache.
    //
    // IN: -
    // OUT: -
    //
    function setLang() {
            global $session,$_GET,$session_adminlang,$lang;
                $session->create("session_adminlang");
                if ($_GET["lang"] != "" && in_array($_GET["lang"], $lang->available)) {
                    $this->language = $_GET["lang"];
                        $session_adminlang = $this->language;
						$_SESSION['session_adminlang'] = $this->language;
                }
                else {
                    if (in_array($_SESSION['session_adminlang'], $lang->available))
                            { $this->language = $session_adminlang;
								$this->language = $_SESSION['session_adminlang'];
							 }
                        else
                            { $this->language = $lang->current; $session_adminlang = $lang->current;
							$_SESSION['session_adminlang'] = $lang->current;
							 }
                }
    }
        // }}}


}
?>